import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAdminStore = defineStore('admin', () => {
  const adminInfo = ref(null)

  // 设置管理员信息
  const setAdminInfo = (info) => {
    adminInfo.value = info
  }

  // 清除管理员信息
  const clearAdminInfo = () => {
    adminInfo.value = null
  }

  const getRole = () => {
    return adminInfo.value?.role
  }

  return {
    adminInfo,
    setAdminInfo,
    clearAdminInfo,
    getRole
  }
}, {
  persist: true
}) 